package com.rockcent.mall.lib.repository;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MarketMerchantProductSales;
import com.rockcent.mall.lib.domain.enumclass.MarketMerchantCooperationStatus;
import com.rockcent.mall.lib.domain.enumclass.MarketMerchantProductSalesStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * Created by DK on 16/9/20.
 * 分销产品
 */
public interface MarketMerchantProductSalesRepository extends JpaRepository<MarketMerchantProductSales, Long>, JpaSpecificationExecutor, MarketMerchantProductSalesRepositoryCustom {


    List<MarketMerchantProductSales> findBySupplierMerchantIdAndDistributorMerchantIdAndIsDelete(Long supplierMerchantId, Long distributorMerchantId,Whether whether);

    /**
     * 供应商/分销商 分销产品数
     * @param supplierMerchantId
     * @param distributorMerchantId
     * @return
     */
    Long countBySupplierMerchantIdAndDistributorMerchantIdAndSupplierStatusAndDistributorStatus(Long supplierMerchantId, Long distributorMerchantId, MarketMerchantProductSalesStatus supplierStatus, MarketMerchantProductSalesStatus distributorStatus);

    MarketMerchantProductSales findByProductIdAndDistributorMerchantIdAndIsDeleteAndSupplierStatusAndDistributorStatus(Long id, Long distributorMerchantId, Whether isDelete, MarketMerchantProductSalesStatus distributorStatus, MarketMerchantProductSalesStatus supplierStatus);

    MarketMerchantProductSales findByProductIdAndDistributorMerchantIdAndSupplierMerchantIdAndIsDeleteAndSupplierStatusAndDistributorStatus(Long marketId, Long id, Long marketMerchantId, Whether no, MarketMerchantProductSalesStatus pass, MarketMerchantProductSalesStatus pass1);

    MarketMerchantProductSales findByProductIdAndDistributorMerchantIdAndSupplierMerchantIdAndIsDeleteAndDistributorStatus(Long productId, Long merchantId, Long supplierMerchantId, Whether no, MarketMerchantProductSalesStatus pass);
}
